package langnstats.project;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

import langnstats.project.lib.LanguageModel;
import langnstats.project.lib.WordType;

public class PredictionWriter {
	
	public static void main(String[] args) throws IOException, ClassNotFoundException{
		if(args.length<1){ throw new IllegalArgumentException("There must be more than 1 arguments! Current argument # = " + args.length); }
		File modelFile = new File(args[0]);
		LanguageModel model = Global.load(modelFile);
		
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String str = null;
        WordType wordType = null;
        do {
        	wordType = WordType.get(str);
        	printPredictions(model.predict(wordType));
        } while ( (str = in.readLine()) != null);
	}
	
	public static void printPredictions(double[] predictions){
		StringBuffer buffer = new StringBuffer();
		for(int i=0; i<predictions.length; i++){
			double d = predictions[i];
			if(i!=0){ buffer.append(' '); }
			buffer.append(d);			
		}
		System.out.println(buffer);
	}
}
